home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_087 / install / scott / myinstal.asm < prev    next >
Assembly Source File  |  1992-05-06  |  7KB  |  273 lines

  1. * myinstal.asm    Copyright 1987 by Scott Turner ALL RIGHTS RESERVED
  2. *
  3. * This program was inspired by the plight of PD authors who could not even do
  4. * an 'INSTALL' command on their PD disks because of a repressive policy on
  5. * the part of Commodore-Amiga Inc. This one is for you guys!
  6. *
  7. * Also a big thanks to MetaComCo for the upgrade to version 11.0 of the Macro
  8. * Assembler. Not only did I get my $27 worth, but I'm tickled pink. Twice as
  9. * fast as the old assembler PLUS new options, and bug fixes. If you don't have
  10. * it yet, get it!
  11. *
  12. * This program writes 1024 bytes into blocks 0 and 1 of the diskette in drive
  13. * DF0:. If someone wishes it could be adapted to take the drive number from
  14. * the command line. But I have two hard disk drives, thus I only have ONE
  15. * floppy disk drive :).
  16. *
  17. * The 'INSTALL' program is VERY VERY VERY ugly! It writes uninitilized data
  18. * from ram onto the disk when it installs it. Myinstal allocates a 1024
  19. * byte buffer from CHIP ram with the 'please clear to zero' bit set so that
  20. * the ram is all nice an zeroed. It then copies in the payload code, calculates
  21. * the checksum and writes the whole thing to disk.
  22. *
  23. * This program is distributed with a 'stock' bootstrap. This bootstrap will
  24. * function like the one used by the INSTALL program. BUT it clears D0 before
  25. * calling OpenLibrary and doesn't do any branching to branches. The potential
  26. * for doing some INTERESTING things in addition to the basic bootstrap 
  27. * requirements DO seem to exist. The code could be modified to print a 
  28. * 'This is NOT a boot disk' type message for example. Or new CLI's and
  29. * console handlers could be installed... Operational parameters not covered
  30. * by prefs could be tweaked. Try not to have too much fun now :-).
  31. *
  32. * If you have questions/comments/requests concerning this source code, please
  33. * direct them in WRITING (no I don't mean via phone!) to:
  34. *
  35. * Scott Turner
  36. * L5 Computing
  37. * 12311 Maplewood Avenue
  38. * Edmonds, WA. 98020-1115
  39. *
  40. * I may also be reached via:
  41. *
  42. * JST on GEnie
  43. * scotty@l5comp.UUCP or stride!l5comp!scotty
  44. *
  45. * I am NOT releasing this source code into the public domain. However, I here
  46. * by grant a license for distribution via AmigaDOS format 3.5" diskette or via
  47. * an online telecommunications medium provided that the party charges less than
  48. * the following to do so:
  49. *
  50. * USA $10 for a copy on an AmigaDOS 3.5" disk.
  51. * USA $10 an hour for 1200 baud connection at 18:00 PST from Seattle, WA USA.
  52. *
  53. * I reserve all other rights. This source code is made available "AS IS" and I
  54. * make no warranties for it's fitness for any purpose.
  55. *
  56. *------------------------------------------------------------------------------
  57. *
  58. * I hate assembling 3,000 lines of include files. How about you?
  59. *
  60. * External EXEC references
  61. _Supervisor    EQU    -6*5
  62. _FindResident    EQU    -6*16
  63. _AllocMem    EQU    -6*33
  64. _FreeMem    EQU    -6*35
  65. _FindTask    EQU    -6*49
  66. _OpenLibrary    EQU    -6*68
  67. _CloseLibrary    EQU    -6*69
  68. _OpenDevice    EQU    -6*74
  69. _CloseDevice    EQU    -6*75
  70. _DOIO        EQU    -6*76
  71. *
  72. * External AmigaDOG references
  73. _Write        EQU    -6*8
  74. _Output        EQU    -6*10
  75. *
  76. * Setup global registers
  77.         MOVEA.L    4,A6            ; ExecBase
  78.         SUBA.L    A4,A4            ; Pointer to memory buffer
  79.         LEA    DiskIOReq(PC),A3    ; Pointer to disk I/O Request
  80.         MOVEQ    #0,D6            ; Completion result
  81.         MOVE.L    A7,D5            ; Stack pointer
  82.         MOVEQ    #1,D4            ; Disk opened flag <>0 <>open
  83. *
  84. * Call the "dog"
  85.         MOVEQ    #0,D0
  86.         LEA    DogName(PC),A1
  87.         JSR    _OpenLibrary(A6)
  88.         MOVEA.L    D0,A5
  89.         TST.L    D0
  90.         BNE.S    LibraryOpen
  91. *
  92. * We arrive here because the system is in a phrase "royally fucked". Since the
  93. * Amiga is not prone to this, some menacing outside influence must have caused
  94. * it. Fight back by dropping a "Neutron bomb" on the rascals.
  95. * This routine has been upgraded from the one in MoonMouse.
  96. FireNeutronBomb    LEA    TheBomb(PC),A5
  97.         JSR    _Supervisor(A6)
  98.         STOP    #$2700
  99.  
  100. TheBomb        MOVE.L    #'HELP',0    ; Shoot the Guru
  101.         ADDQ.L    #1,A7    ; The ONE hole in the 680X0's protection...
  102. *
  103. * "So long mom, I'm off to drop the bomb."
  104.         RTE
  105.  
  106. *
  107. * Allocate some CHIP ram for payload.
  108. LibraryOpen    MOVE.L    #$10002,D1
  109.         MOVE.L    #1024,D0    ; Boot block size
  110.         JSR    _AllocMem(A6)
  111.         TST.L    D0
  112.         BEQ.S    MissedIt
  113.         MOVEA.L    D0,A4
  114. *
  115. * Now we copy the payload into the memory buffer. While doing so we calculate
  116. * the checksum which we will patch into the buffer after the copy.
  117.         MOVEQ    #0,D2        ; Zero checksum
  118.         MOVEQ    #PayloadSize/4-1,D0
  119.         MOVEA.L    A4,A1
  120.         LEA    ThePayload(PC),A0
  121. 0$        MOVE.L    (A0)+,D1
  122.         MOVE.L    D1,(A1)+    ; Shove into buffer
  123.         ADD.L    D1,D2        ; Bump checksum
  124.         BCC.S    1$        ; Did it rollover?
  125.         ADDQ.L    #1,D2        ; Bump by 1 if it rolled
  126. 1$        DBF    D0,0$
  127. *
  128. * Patch checksum into buffer
  129.         NOT.L    D2
  130.         MOVE.L    D2,4(A4)
  131. *
  132. * Init the port to use to access the trackdisk.device
  133.         SUBA.L    A1,A1
  134.         JSR    _FindTask(A6)
  135.         LEA    DiskPort(PC),A0
  136.         MOVE.L    D0,16(A0)
  137. *
  138. * Open the disk device
  139.         MOVEQ    #0,D1
  140.         MOVEQ    #0,D0
  141.         MOVEA.L    A3,A1
  142.         LEA    DiskName(PC),A0
  143.         JSR    _OpenDevice(A6)
  144.         MOVE.L    D0,D4            ; Record if we opened device
  145.         BNE.S    MissedIt
  146. *
  147. * Write payload to the disk 
  148.         MOVEA.L    A3,A1
  149.         MOVE.L    A4,40(A1)        ; Pointer to Payload buffer
  150.         JSR    _DOIO(A6)
  151.         TST.L    D0
  152.         BNE.S    MissedIt
  153. *
  154. * Flush data from track buffer onto the disk
  155.         MOVEA.L    A3,A1
  156.         MOVE.W    #4,28(A1)
  157.         JSR    _DOIO(A6)
  158.         TST.L    D0
  159.         BNE.S    MissedIt
  160. *
  161. * Shutdown the motor
  162.         MOVEA.L    A3,A1
  163.         MOVE.W    #9,28(A1)
  164.         CLR.L    36(A1)
  165.         JSR    _DOIO(A6)
  166.         TST.L    D0
  167.         BEQ.S    MadeIt
  168.  
  169. MissedIt    MOVE.L    D0,D6        ; Record error
  170.         LEA    Ooops(PC),A0
  171.         MOVEA.L    A0,A1
  172.         MOVE.L    A0,D3
  173. 0$        TST.B    (A0)+
  174.         BNE.S    0$
  175.         SUBA.L    D3,A0
  176.         MOVE.L    A0,D3
  177.         SUBQ.L    #1,D3        ;Length
  178.         MOVE.L    A1,D2        ;Buffer
  179.         JSR    _Output(A5)
  180.         MOVE.L    D0,D1        ;FileHandle
  181.         JSR    _Write(A5)
  182. *
  183. * Send the dog home
  184. MadeIt        MOVEA.L    A5,A1
  185.         JSR    _CloseLibrary(A6)
  186. *
  187. * Free up the memory buffer if it was allocated
  188.         MOVE.L    A4,D0
  189.         BEQ.S    0$
  190.         MOVEA.L    D0,A1
  191.         MOVE.L    #1024,D0
  192.         JSR    _FreeMem(A6)
  193. *
  194. * Close the disk if we opened it
  195. 0$        TST.L    D4
  196.         BNE.S    1$
  197.         MOVEA.L    A3,A1
  198.         JSR    _CloseDevice(A6)
  199. 1$        MOVE.L    D6,D0
  200.         MOVEA.L    D5,A7
  201.         RTS
  202.  
  203.         CNOP    0,4
  204. *
  205. * Payload, this is the code written to the disk's boot block
  206. PayloadStart
  207. ThePayload    DC.B    'DOS',0
  208.         DC.L    0    ; Checksum goes here
  209.         DC.L    880    ; Root block
  210.  
  211. *
  212. * Do NOT change the statements above here, they are cast in the sands of time.
  213. * From here on down is where you can insert a new bootstrap routine.
  214. * Instead of doing the stuff below code could be inserted to throw up an
  215. * alert telling the user that this is NOT a bootdisk.
  216. * The following code may seem a tad 'weird', this is intentional. The original
  217. * Copyrighted boostrap was so small that rewriting it without directly copying
  218. * it was a tad tricky. But where there is a will there IS a way! :-)
  219.         LEA    DogName(PC),A1
  220.         JSR    _FindResident(A6)
  221.         TST.L    D0
  222.         BEQ.S    DingDongTheDogIsDead
  223.         SUBA.L    A0,A0
  224.         MOVE.L    22(A0,D0.L),A0
  225.         EOR.L    D0,D0
  226.         RTS
  227.  
  228. DogName        DC.B    'dos.library',0
  229.  
  230. DingDongTheDogIsDead
  231.         MOVEQ    #-1,D0
  232.         RTS
  233.  
  234.         CNOP    0,4
  235. PayloadEnd
  236. PayloadSize    EQU    PayloadEnd-PayloadStart
  237.  
  238. DiskName    DC.B    'trackdisk.device',0
  239. Ooops        DC.B    'Disk was NOT installed',$A,0
  240.         DS.W    0
  241.  
  242. DiskPort    DC.L    0    ;0
  243.         DC.L    0    ;4
  244.         DC.W    $0400    ;8
  245.         DC.L    0    ;10
  246.         DC.B    0    ;14
  247.         DC.B    31    ;15
  248.         DC.L    0    ;16    Task addr goes here
  249. LH1        DC.L    LH2    ;20
  250. LH2        DC.L    0    ;24
  251.         DC.L    LH1    ;28
  252.         DC.B    0    ;32
  253.         DC.B    0    ;33
  254. DiskIOReq    DC.L    0    ;0
  255.         DC.L    0    ;4
  256.         DC.B    5    ;8
  257.         DC.B    0    ;9
  258.         DC.L    0    ;10
  259.         DC.L    DiskPort ;14
  260.         DC.W    48    ;18
  261.         DC.L    0    ;20
  262.         DC.L    0    ;24
  263.         DC.W    3    ;28 IO_CMD
  264.         DC.W    0    ;30
  265.         DC.L    0    ;32
  266.         DC.L    1024    ;36 IO_LENGTH
  267.         DC.L    0    ;40 IO_DATA
  268.         DC.L    0    ;44 IO_OFFSET
  269.         DC.L    0
  270.         DC.L    0
  271.  
  272.         END
  273.